<?php
class NoticeUrl {
    /****
    * 判定账户为user还是group从而返回相应个人主页url
    * @data 账户值，应当包含uid和role字段
    */
    static public function getAccount($data, $role=null){
        import('@.Model.AccountModel');
        if (is_numeric($data)){
            $uid= $data;
        } else{
            $uid= $data['uid'];
            $role= $data['role'];
            if (!$uid){
                $uid= $data['author_id'];
            }
        }
        if (AccountModel::C('ROLE_GROUP') ==$role){
            $url= U('Home-group/'.$uid);
        } else if (AccountModel::C('ROLE_USER_BASIC') ==$role){
            $url= U('Home-user/'.$uid);
        } else{
            $url= U('Home-user/'.$uid);
        }
        return $url;
    }
    /****
    * 海报路径
    * @size 图片大小
    *       'm',
    *       '','l'
    */
    static public function getEventPoster($filename, $size=null){
        if (!$filename){
            $filename= 'default.png';
        } else{
            if ($size){
                $filename= $size.'_'.$filename;
            }
        }
        
        $TMPL_PATHS= C('TMPL_PARSE_STRING');
        return $TMPL_PATHS['__UPLOAD__']."/poster/$filename";
    }
    /****
    * 活动照片路径
    */
    static public function getEventImage($filename, $size=null){
        if (!$filename){
            $filename= 'default.png';
        }
        if ($size){
            $filename= $size.'_'.$filename;
        }
        
        $TMPL_PATHS= C('TMPL_PARSE_STRING');
        return $TMPL_PATHS['__UPLOAD__']."/image/event/$filename";
    }
    static public function realEventPoster(){
        return (C('UPLOAD_PATH').'/poster/');
    }
    static public function realEventImage(){
        return (C('UPLOAD_PATH').'/image/event/');
    }
    /****
    * 修改头像地址
    */
    static public function setAvatar($uid, $type='middle'){
        import('@.Common.UCAdapter');
        return UCAdapter::get()->avatar($uid, $type);
    }
    static public function getPhoto($uid, $type='middle'){
        return C('UC_API')."/avatar.php?uid=$uid&size=$type";
    }
}
?>